import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
import FluentUI
import "qrc:/component"
Item {
    id: app

    Connections{
        target: FluTheme
        function onDarkModeChanged(){
            SettingsHelper.saveDarkMode(FluTheme.darkMode)
        }
    }

    Connections{
        target: FluApp
        function onVsyncChanged(){
            SettingsHelper.saveVsync(FluApp.vsync)
        }
    }

    FluHttpInterceptor{
        id:interceptor
        function onIntercept(request){
            if(request.method === "get"){
                request.params["method"] = "get"
            }
            if(request.method === "post"){
                request.params["method"] = "post"
            }
            request.headers["token"] ="yyds"
            request.headers["os"] ="pc"
            console.debug(JSON.stringify(request))
            return request
        }
    }
    Component.onCompleted: {
            FluApp.init(app)
            FluApp.vsync = SettingsHelper.getVsync()
            FluTheme.darkMode = SettingsHelper.getDarkMode()
            FluTheme.enableAnimation = true
            FluApp.routes = {
                "/":"qrc:/window/MainWindow.qml",
                "/login":"qrc:/window/LoginWindow.qml",
            }
            FluApp.initialRoute = "/login"
            FluApp.run()
        }
    }


